package com.brillilab.service.core.method.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.brillilab.dao.mapper.method.MethodRelateTimerMapper;
import com.brillilab.domain.po.method.MethodRelateTimer;
import com.brillilab.service.core.method.IMethodRelateTimerService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author wuzhiyu
 * @Title: MethodRelateTimerServiceImpl
 * @ProjectName brill_lab
 * @Description: TODO
 * @date 2019/4/3011:20
 */
@Service
@Transactional
public class MethodRelateTimerServiceImpl implements IMethodRelateTimerService {
    @Resource
    private MethodRelateTimerMapper methodRelateTimerMapper;
    @Override
    public List<MethodRelateTimer> getByMethodId(Long methodId) {
        LambdaQueryWrapper<MethodRelateTimer> query = new LambdaQueryWrapper<>();
        query.eq(MethodRelateTimer::getMethodId,methodId);
        return methodRelateTimerMapper.selectList(query);
    }

    @Override
    public boolean saveList(List<MethodRelateTimer> timerList) {
        return methodRelateTimerMapper.saveList(timerList)>0;
    }

    @Override
    public List<MethodRelateTimer> listByStepId(Long stepId) {
        return methodRelateTimerMapper.selectList(
                new LambdaQueryWrapper<MethodRelateTimer>()
                        .eq(MethodRelateTimer::getStepId,stepId));
    }
}
